package net.thxjj.adminServer.service.impl;

import java.util.HashMap;
import java.util.List;

import net.thxjj.sitermodel.Cmdation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.thxjj.adminServer.dao.CmdationDao;
import net.thxjj.adminServer.entity.ResponseModel;
import net.thxjj.adminServer.entity.ResultEnum;
import net.thxjj.adminServer.service.iCmdationService;
import net.thxjj.adminServer.util.ParameterMap;

@Service
public class CmdationService implements iCmdationService{
	private Logger log = Logger.getLogger(this.getClass());
	@Autowired
	private CmdationDao cmdationDao;
	
	@Override
	public List<Cmdation> list(String prod_key) {
		// TODO Auto-generated method stub
		return cmdationDao.list(prod_key);
	}

	@Override
	public Cmdation getCmdation(long cmdId, String prod_key) {
		return cmdationDao.getCmdation(cmdId,prod_key);
	}


	@Override
	public HashMap<String, Object> addCmdation(ParameterMap pm) {
		// TODO Auto-generated method stub
		try {
			cmdationDao.addCmdation(pm);
		}catch(Exception e) {
			log.error("error:"+e.getMessage(), e);
			return ResponseModel.getModel(ResultEnum.ERROR, null);
		}
		return ResponseModel.getModel(ResultEnum.SUCCESS, null);
	}

	@Override
	public HashMap<String, Object> editCmdation(ParameterMap pm) {
		try {
			cmdationDao.editCmdation(pm);
		}catch(Exception e) {
			log.error("error:"+e.getMessage(), e);
			return ResponseModel.getModel(ResultEnum.ERROR, null);
		}
		return ResponseModel.getModel(ResultEnum.SUCCESS, null);
	}

	@Override
	public HashMap<String, Object> del(long cmdId, String prod_key) {
		try {
			cmdationDao.deleteCmdation(cmdId,prod_key);
		}catch(Exception e) {
			log.error("error:"+e.getMessage(), e);
			return ResponseModel.getModel(ResultEnum.ERROR, null);
		}
		return ResponseModel.getModel(ResultEnum.SUCCESS, null);
	}


}
